package com.wenlin.image.controller;

import com.wenlin.image.response.Message;
import com.wenlin.image.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/***
 *  Created with IntelliJ IDEA.
 *  User:  wenlin
 *  Date:  2017/12/6
 *  Time:  14:50
 *  Description:
 **/
@RestController
@RequestMapping("/image")
public class ImageController {
    @Autowired
    private ImageService imageService;
    @RequestMapping(value = "/avatar", method = RequestMethod.POST)
    public Message uploadAndModify(@RequestParam("userId") String userId, @RequestParam("pictureFile") MultipartFile pictureFile) {

        Assert.hasLength(userId, "参数不能为空");

        return imageService.process(userId,pictureFile);
    }

}
